package cn.bingoogolapple.bgabanner.transformer;

import ohos.agp.components.Component;

/**
 * 作者:王浩 邮件:bingoogolapple@gmail.com
 * 创建时间:15/6/19 上午8:41
 * 描述:
 */
public class AlphaPageTransformer extends BGAPageTransformer {
    private float mMinScale = 0.4f;

    /**
     * AlphaPageTransformer
     */
    public AlphaPageTransformer() {
    }

    /**
     * AlphaPageTransformer
     *
     * @param minScale
     */
    public AlphaPageTransformer(float minScale) {
        setMinScale(minScale);
    }

    @Override
    public void handleInvisiblePage(Component view, float position) {
        view.setAlpha(0);
    }

    @Override
    public void handleLeftPage(Component view, float position) {
        view.setAlpha(mMinScale + (1 - mMinScale) * (1 + position));
    }

    @Override
    public void handleRightPage(Component view, float position) {
        view.setAlpha(mMinScale + (1 - mMinScale) * (1 - position));
    }

    /**
     * setMinScale
     *
     * @param minScale
     */
    public void setMinScale(float minScale) {
        if (minScale >= 0.0f && minScale <= 1.0f) {
            mMinScale = minScale;
        }
    }
}